package sagroup.dracots;


/**
 * This is a reaction to deal with CommandTuples.
 * 
 * @author Huang Xiaodong
 */

public class CommandReaction extends DracoReaction {
	/**
	 * Constructor method. Performs parameter checking.
	 * 
	 * @param mode
	 *            Reaction.ONCE or Reaction.ONCEPERTUPLE
	 * @param dts
	 *            current tuple space that use this command reaction
	 */
	public CommandReaction(byte mode, DracoTS dts) {
		super(mode, Templates.CT_LOCAL_TEMPLATE,
				new CommandReactionListener(dts));
	}

	/**
	 * toString method.
	 * 
	 * @return textual representation of a reaction
	 */
	@Override
	public String toString() {
		String msg = "[CommandReaction] mode=";
		switch (super.getMode()) {
		case ONCE:
			msg = msg + "ONCE";
			break;
		case ONCEPERTUPLE:
			msg = msg + "ONCEPERTUPLE";
			break;
		}
		return msg + " template=" + super.getTemplate() + " listener="
				+ super.getListener().getClass().getName();
	}
}
